cmake_minimum_required(VERSION 3.5)

project(opengl LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)



#Glfw3
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/third_party/glfw/include")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/third_party/glfw/")


#fmt
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/third_party/fmt/include")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/third_party/fmt/")

#nameof
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/third_party/nameof/include")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/third_party/nameof/")

#imgui
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/third_party/imgui")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/third_party/imgui/backends")
file(GLOB sources "${CMAKE_CURRENT_SOURCE_DIR}/third_party/imgui/*.cpp")
file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/third_party/imgui/*.h")
set(BACKENDS_OPENGL_GLFW 
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/imgui/backends/imgui_impl_glfw.h"
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/imgui/backends/imgui_impl_glfw.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/imgui/backends/imgui_impl_opengl3.h"
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/imgui/backends/imgui_impl_opengl3.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/imgui/backends/imgui_impl_opengl3_loader.h"
)
add_library(imgui ${BACKENDS_OPENGL_GLFW} ${sources} ${headers} )


#assimp
set(BUILD_SHARED_LIBS ON)
set(ASSIMP_BUILD_TESTS OFF)
set(ASSIMP_INSTALL OFF)
set(ASSIMP_WARNINGS_AS_ERRORS OFF)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/third_party/assimp/include")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/third_party/assimp/")

#glm
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/third_party/glm")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/third_party/glm/")



if(CMAKE_SYSTEM_NAME MATCHES "Windows")
    add_definitions(-DXXD_WIN32)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
    add_definitions(-DXXD_LINUX)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
    add_definitions(-DXXD_MACOS)
endif()


if(CMAKE_BUILD_TYPE MATCHES "Debug" )
    add_definitions(-DDEBUG)  
elseif(CMAKE_BUILD_TYPE MATCHES "Release" AND MSVC)
    target_link_options(${CMAKE_PROJECT_NAME} PRIVATE "/SUBSYSTEM:WINDOWS")
    add_definitions(-Dmain=WinMain)
elseif(CMAKE_BUILD_TYPE MATCHES "Release" AND MINGW)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mwindows")
endif()

add_subdirectory(src)

